import $ from "jquery";
import styles from "./index.module.less";

let containerEl = null;

function init() {
  containerEl = $("<div>").addClass(styles.container).appendTo("#app");
}

init();

export function createMovieTag(movies) {
  containerEl[0].innerHTML = movies
    .map(
      (m) =>
        `<div class="${styles.items}">
          <a href="${m.url}" target="_blank">
            <img class="${styles.cover}" src="${m.cover}" alt="${m.title}" />
          </a>
          <a href="${m.url}" target="_blank">
            <span class="${styles.title}">${m.title}</span>
          </a>
          <span class="${styles.rate}">评分 ${m.rate}</span>
        </div>`
    )
    .join("");
}
